package com.cloudsigns.factorymanager2.produce.bean;

import android.text.TextUtils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class WorkPartHandOverOrderBean implements Serializable {
    private long checkDate;// 验收时间
    private int concessionAmount;// 让步数量
    private String concessionReason;// 让步原因
    private String handInAccountId;// 提交人账号ID
    private String handInAccountName;//	提交人账号名称
    private int handInAmount;//	提交数量
    private long handInDate;// 交接时间
    private String handOverAccountId;//	交接接收人账号ID
    private String handOverAccountName;// 交接接收人账号名称
    private long handOverDate;// 交接接收时间
    private String handOverWorkPartId;// 交接接收方工序ID
    private String id;// mid
    private String produceLeaderAccountId;// 管理员账号ID，最后一道工序需要
    private int qualifiedAmount;// 合格数量
    private int returnAmount;//	退回数量
    private List<String> returnImgUrlList = new ArrayList<>();// 退回图片
    private String returnReason;// 退回原因
    private String status;// 交接状态
    private String workPartId;// 工序Id

    public String getDescript(String strUnit) {
        String desc = "";
        if (concessionAmount > 0) {
            desc += "让步接收" + concessionAmount + strUnit+"/";
        }
        if (qualifiedAmount > 0) {
            desc += "合格" + qualifiedAmount +  strUnit+"/";
        }
        if (returnAmount > 0) {
            desc += "退回" + returnAmount+strUnit;
        }
        return desc;
    }

    public long getCheckDate() {
        return checkDate;
    }

    public void setCheckDate(long checkDate) {
        this.checkDate = checkDate;
    }

    public int getConcessionAmount() {
        return concessionAmount;
    }

    public void setConcessionAmount(int concessionAmount) {
        this.concessionAmount = concessionAmount;
    }

    public String getConcessionReason() {
        return concessionReason;
    }

    public void setConcessionReason(String concessionReason) {
        this.concessionReason = concessionReason;
    }

    public String getHandInAccountId() {
        return handInAccountId;
    }

    public void setHandInAccountId(String handInAccountId) {
        this.handInAccountId = handInAccountId;
    }

    public String getHandInAccountName() {
        return handInAccountName;
    }

    public void setHandInAccountName(String handInAccountName) {
        this.handInAccountName = handInAccountName;
    }

    public int getHandInAmount() {
        return handInAmount;
    }

    public void setHandInAmount(int handInAmount) {
        this.handInAmount = handInAmount;
    }

    public long getHandInDate() {
        return handInDate;
    }

    public void setHandInDate(long handInDate) {
        this.handInDate = handInDate;
    }

    public String getHandOverAccountId() {
        return handOverAccountId;
    }

    public void setHandOverAccountId(String handOverAccountId) {
        this.handOverAccountId = handOverAccountId;
    }

    public String getHandOverAccountName() {
        return handOverAccountName;
    }

    public void setHandOverAccountName(String handOverAccountName) {
        this.handOverAccountName = handOverAccountName;
    }

    public long getHandOverDate() {
        return handOverDate;
    }

    public void setHandOverDate(long handOverDate) {
        this.handOverDate = handOverDate;
    }

    public String getHandOverWorkPartId() {
        return handOverWorkPartId;
    }

    public void setHandOverWorkPartId(String handOverWorkPartId) {
        this.handOverWorkPartId = handOverWorkPartId;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getProduceLeaderAccountId() {
        return produceLeaderAccountId;
    }

    public void setProduceLeaderAccountId(String produceLeaderAccountId) {
        this.produceLeaderAccountId = produceLeaderAccountId;
    }

    public int getQualifiedAmount() {
        return qualifiedAmount;
    }

    public void setQualifiedAmount(int qualifiedAmount) {
        this.qualifiedAmount = qualifiedAmount;
    }

    public int getReturnAmount() {
        return returnAmount;
    }

    public void setReturnAmount(int returnAmount) {
        this.returnAmount = returnAmount;
    }

    public List<String> getReturnImgUrlList() {
        return returnImgUrlList;
    }

    public void setReturnImgUrlList(List<String> returnImgUrlList) {
        this.returnImgUrlList = returnImgUrlList;
    }

    public String getReturnReason() {
        return returnReason;
    }

    public void setReturnReason(String returnReason) {
        this.returnReason = returnReason;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getWorkPartId() {
        return workPartId;
    }

    public void setWorkPartId(String workPartId) {
        this.workPartId = workPartId;
    }

    public void parseJson(JSONObject jsonObj) throws JSONException {
        if (jsonObj.has("checkDate")) {
            String checkDateStr = jsonObj.getString("checkDate");
            if (!TextUtils.isEmpty(checkDateStr) && !checkDateStr.equals("null")) {
                setCheckDate(Long.parseLong(checkDateStr));
            }
        }
        if (jsonObj.has("concessionAmount")) {
            String concessionAmountStr = jsonObj.getString("concessionAmount");
            if (null != concessionAmountStr && !TextUtils.isEmpty(concessionAmountStr) && !"null".equals(concessionAmountStr)) {
                setConcessionAmount(Integer.parseInt(concessionAmountStr));
            }
        }
        if (jsonObj.has("concessionReason")) {
            setConcessionReason(jsonObj.getString("concessionReason"));
        }
        if (jsonObj.has("handInAccountId")) {
            setHandInAccountId(jsonObj.getString("handInAccountId"));
        }
        if (jsonObj.has("handInAccountName")) {
            setHandInAccountName(jsonObj.getString("handInAccountName"));
        }
        if (jsonObj.has("handInAmount")) {
            String handInAmountStr = jsonObj.getString("handInAmount");
            if (null != handInAmountStr && !TextUtils.isEmpty(handInAmountStr) && !"null".equals(handInAmountStr)) {
                setHandInAmount(Integer.parseInt(handInAmountStr));
            }
        }
        if (jsonObj.has("handInDate")) {
            String handInDateStr = jsonObj.getString("handInDate");
            if (!TextUtils.isEmpty(handInDateStr) && !handInDateStr.equals("null")) {
                setHandInDate(Long.parseLong(handInDateStr));
            }
        }
        if (jsonObj.has("handOverAccountId")) {
            setHandOverAccountId(jsonObj.getString("handOverAccountId"));
        }
        if (jsonObj.has("handOverAccountName")) {
            setHandOverAccountName(jsonObj.getString("handOverAccountName"));
        }
        if (jsonObj.has("handOverDate")) {
            String handOverDateStr = jsonObj.getString("handOverDate");
            if (!TextUtils.isEmpty(handOverDateStr) && !handOverDateStr.equals("null")) {
                setHandOverDate(Long.parseLong(handOverDateStr));
            }
        }
        if (jsonObj.has("handOverWorkPartId")) {
            setHandOverWorkPartId(jsonObj.getString("handOverWorkPartId"));
        }
        if (jsonObj.has("id")) {
            setId(jsonObj.getString("id"));
        }
        if (jsonObj.has("produceLeaderAccountId")) {
            setProduceLeaderAccountId(jsonObj.getString("produceLeaderAccountId"));
        }
        if (jsonObj.has("returnAmount")) {
            String returnAmountStr = jsonObj.getString("returnAmount");
            if (null != returnAmountStr && !TextUtils.isEmpty(returnAmountStr) && !"null".equals(returnAmountStr)) {
                setReturnAmount(Integer.parseInt(returnAmountStr));
            }
        }
        if (jsonObj.has("qualifiedAmount")) {
            String qualifiedAmountStr = jsonObj.getString("qualifiedAmount");
            if (null != qualifiedAmountStr && !TextUtils.isEmpty(qualifiedAmountStr) && !"null".equals(qualifiedAmountStr)) {
                setQualifiedAmount(Integer.parseInt(qualifiedAmountStr));
            }
        }
        if (jsonObj.has("returnImgUrlList")) {
            String returnImgUrlListJsonArrStr = jsonObj.getString("returnImgUrlList");
            if (null != returnImgUrlListJsonArrStr && !returnImgUrlListJsonArrStr.equals("null") && !TextUtils.isEmpty(returnImgUrlListJsonArrStr)) {
                JSONArray imgUrlListJsonArr = new JSONArray(returnImgUrlListJsonArrStr);
                ArrayList<String> imgUrlList = new ArrayList<String>();
                for (int m = 0; m < imgUrlListJsonArr.length(); m++) {
                    imgUrlList.add(imgUrlListJsonArr.getString(m));
                }
                setReturnImgUrlList(imgUrlList);
            }
        }
        if (jsonObj.has("returnReason")) {
            setReturnReason(jsonObj.getString("returnReason"));
        }
        if (jsonObj.has("status")) {
            setStatus(jsonObj.getString("status"));
        }
        if (jsonObj.has("workPartId")) {
            setWorkPartId(jsonObj.getString("workPartId"));
        }
    }
}
